package com.zixuan.gulicollege.eduservice.controller;


import com.zixuan.gulicollege.common_utils.R;
import com.zixuan.gulicollege.eduservice.service.EduSubjectService;
import com.zixuan.gulicollege.entity.eduservice.subject.OneSubject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zixuan
 * @since 2021-05-06
 */
@RestController
@RequestMapping("/edu_service/subject")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    /**
     * 添加课程分类
     * @param file
     * @return
     */
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        subjectService.saveSubject(file, subjectService);

        return R.ok();
    }


    /**
     * 获取所有分类
     * @return
     */
    @GetMapping("/getAllSubject")
    public R getAllSubject(){
        List<OneSubject> list = subjectService.getAllOneTwoSubject();

        return R.ok().data("list", list);
    }

}

